#include<vector>
#include<string>
#include<algorithm>
using namespace std;
class Solution {
public:
    int maxProduct(vector<string>& words) {
        int n = words.size();
        int* mask = new int[n];
        int* len = new int[n];
        for (int i = 0; i < n; ++i) {
            int bitmask = 0;
            for (char c : words[i]) {
                bitmask |= 1 << (c - 'a');
            }
            mask[i] = bitmask;
            len[i] = words[i].size();
        }
        int res = 0;
        for (int i = 0; i < words.size(); ++i) {
            for (int j = i + 1; j < words.size(); ++j) {
                if ((mask[i] & mask[j]) == 0) {
                    res = max(res, len[i] * len[j]);
                }
            }
        }
        return res;
    }
};